home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / DESK / CORE / Desk / h / JumpRaw < prev    next >
Text File  |  1996-08-16  |  2KB  |  76 lines

  1.  
  2. #ifndef __Desk_JumpRaw_h
  3. #define __Desk_JumpRaw_h
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <setjmp.h>
  8. #ifndef __Desk_Debug_h
  9. #include "Desk.Debug.h"
  10. #endif
  11. typedef struct {
  12. jmp_buf jmpbuf;
  13. #ifdef Desk__using_SDLS
  14. int Desk_jump__sdls_stackptr;
  15. #endif
  16. }
  17. Desk_jump_buf;
  18. #ifdef Desk__using_SDLS
  19. #include "Desk.Core.h"
  20. #define Desk_Jump_SetJmp(buf) ((buf).Desk_jump__sdls_stackptr=_dll_setjmp(), setjmp((buf).jmpbuf))
  21. #define Desk_Jump_ReceiveLongJmp(buf) _dll_longjmped((buf).Desk_jump__sdls_stackptr)
  22. #else
  23. #define Desk_Jump_SetJmp(buf) setjmp((buf).jmpbuf)
  24. #define Desk_Jump_ReceiveLongJmp(buf)
  25. #endif
  26. #define Desk_Jump_LongJmp(buf, val) longjmp((buf).jmpbuf, val)
  27. typedef struct Desk_jumpauto_buf {
  28. Desk_jump_buf jumpbuf;
  29. struct Desk_jumpauto_buf* previous;
  30. }
  31. Desk_jumpauto_buf;
  32. #ifdef Desk__using_SDLS
  33. extern Desk_jumpauto_buf** Desk_Jump__Ref_autonewestbuf(void);
  34. #endif
  35. #if defined(Desk__using_SDLS) && !defined(Desk__making_Jump)
  36. #define Desk_jumpauto_newestbuf (*Desk_Jump__Ref_autonewestbuf())
  37. #else
  38. extern Desk_jumpauto_buf *Desk_jumpauto_newestbuf;
  39. #endif
  40. #define Desk_JumpAuto__EscapeFromNestedTryUsingReturnOrBreak() \
  41. (Desk_jumpauto_newestbuf!=&Desk_jumpauto__localbuf)
  42. #define Desk_JumpAuto__Push(jumpautobuf) \
  43. (jumpautobuf).previous = Desk_jumpauto_newestbuf; \
  44. Desk_jumpauto_newestbuf = &(jumpautobuf)
  45. #define Desk_JumpAuto__Pop(jumpautobuf) \
  46. Desk_jumpauto_newestbuf = (jumpautobuf).previous
  47. #define Desk_JumpAuto_Try \
  48. { \
  49. Desk_jumpauto_buf Desk_jumpauto__localbuf; \
  50. volatile int Desk_jumpauto_val; \
  51. Desk_JumpAuto__Push(Desk_jumpauto__localbuf); \
  52. Desk_jumpauto_val = Desk_Jump_SetJmp(Desk_jumpauto__localbuf.jumpbuf); \
  53. \
  54. if (!Desk_jumpauto_val) {
  55. #define Desk_JumpAuto_Catch \
  56. \
  57. \
  58. Desk_JumpAuto__Pop(Desk_jumpauto__localbuf); \
  59. } \
  60. else { \
  61. \
  62. Desk_JumpAuto__Pop(Desk_jumpauto__localbuf); \
  63. Desk_Jump_ReceiveLongJmp(Desk_jumpauto__localbuf.jumpbuf);
  64. #define Desk_JumpAuto_EndCatch \
  65. } \
  66. }
  67. #define Desk_JumpAuto_Throw(val) Desk_Jump_LongJmp(Desk_jumpauto_newestbuf->jumpbuf, val)
  68. #define Desk_JumpAuto_TryCatch(trycode, catchcode) \
  69. Desk_JumpAuto_Try { trycode } \
  70. Desk_JumpAuto_Catch { catchcode } \
  71. Desk_JumpAuto_EndCatch
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif
  76.